package com.rzcf.blink.pay.domain.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;
import top.tangyh.basic.interfaces.BaseEnum;

import java.util.Arrays;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * @author dongsufeng
 * @description: 支付类型
 * @date 2025-09-13 11:51
 */
public enum PayTypeEnum implements BaseEnum {
    NONE("0", "无", "0"),
    WECHAT("1", "微信", "1"),
    ALIPAY("2", "支付宝", "2");

    @EnumValue
    private final String code;
    private final String describe;
    private final String relationCode;
    private static final Map<String, PayTypeEnum> ENUM_MAP = Arrays.stream(values()).collect(Collectors.toMap(PayTypeEnum::getCode, (type) -> type));

    @JsonValue
    @Override
    public String getCode() {
        return this.code;
    }

    @Override
    public String getDesc() {
        return this.describe;
    }

    public String getRelationCode() {
        return this.relationCode;
    }

    @JsonCreator
    public static PayTypeEnum getByCode(String code) {
        return (PayTypeEnum)ENUM_MAP.get(code);
    }

    public String getDescribe() {
        return this.describe;
    }

    private PayTypeEnum(final String code, final String describe, final String relationCode) {
        this.code = code;
        this.describe = describe;
        this.relationCode = relationCode;
    }
}
